package agentsSME;


import java.util.LinkedList;

/**
 * Represents a contact-book of a SME. 
 * <p>
 * The contact list is built up by a SME's neighbours and partners in emergency.
 * All the edges between two SMEs created in networks will be a source to add new contact in a SME's contact-book.
 * </p>
 * @author Chunhui Li
 *
 */

public class ContactsOfSme {
    private Networking net;
    private LinkedList<Object> contactBook; //maybe put SME objects in the map???
    private SME sme;
    
    /**
     * The constructor.
     * @param sme the SME that a ContactsOfSME object belongs to.
     */
	public ContactsOfSme(SME sme) {
		this.sme = sme;
		contactBook = new LinkedList<Object>();
		net = new Networking(sme.companyName);
//		initialise();
	}
	
	/**
	 * Initialisation of the contact book, which adds neighbours into it
	 */
	public void initialise(){
		LinkedList<SME> neighbourList = sme.getNeighbours();
		for (int i=0; i< neighbourList.size(); i++){
			addNewContact(neighbourList.get(i), true, 0.5);
			System.out.println("*neighbour list of*"+sme.companyName+" has "+neighbourList.get(i).companyName);
		}
	}
	
    /**
     * Add a new contact into the contact book.
     * @param target is the new contact SME company
     * @param isDirected
     * @param weight  is the weight of the relationship
     */
	public void addNewContact(SME target, boolean isDirected, double weight){
		net.createSmeEdge(sme, target, isDirected, weight);
		contactBook.add(target);
		System.out.println(this.sme.companyName+" has built the relationship with "+target.companyName);
	}
	
	public void addOtherContact(Object target, boolean isDirected){
		net.createOrganizationEdge(sme, target, isDirected);
		contactBook.add(target);
	}
	
	public LinkedList<Object> getContactBook(){
		return contactBook;
	}
}
